# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>

_realname=libltdl
_parentname=libtool
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.4.6
pkgrel=21
pkgdesc="A system independent dlopen wrapper for GNU libtool (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://www.gnu.org/software/libtool"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
provides=("${MINGW_PACKAGE_PREFIX}-libtool")
conflicts=("${MINGW_PACKAGE_PREFIX}-libtool")
replaces=("${MINGW_PACKAGE_PREFIX}-libtool")
source=("https://ftp.gnu.org/pub/gnu/libtool/${_parentname}-${pkgver}.tar.xz"{,.sig})
sha256sums=('7c87a8c2c8c0fc9cd5019e402bed4292462d00a718a7cd5f11218153bf28b26f'
            'SKIP')
validpgpkeys=('CFE2BE707B538E8B26757D84151308092983D606') #Gary Vaughan (Free Software Developer) <gary@vaughan.pe>

prepare() {
  cd ${srcdir}/${_parentname}-${pkgver}/libltdl

  autoreconf -fvi
}

build() {
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}

  export lt_cv_deplibs_check_method='pass_all'

  ../${_parentname}-${pkgver}/libltdl/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --enable-ltdl-install

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR="${pkgdir}" install
}
